import React, { Component } from 'react'
import { connect } from 'react-redux'
import { increment } from '../actions/counter';
import { counterCreator } from '../actions';

export class Redux extends Component {
    constructor(props) {
        super(props);
        this.state={

        }
    }
    componentDidMount(){
    }

    handleClick=()=>{
        console.log(this.props)
        this.props.increment()
    }
    render() {
        return (
            <div>
                {this.props.$$num}
                <button onClick={this.handleClick}>点我</button>
            </div>
        )
    }
}

const mapStateToProps = (state) => {
    console.log(state)
    return{
        $$num:state.counter.num
    }
}

const mapDispatchToProps = (dispatch)=>({
    increment:()=>dispatch(counterCreator.increment())
})

export default connect(mapStateToProps, mapDispatchToProps)(Redux)
